#include <iostream>

using std::cout;
using std::endl;

class Base
{
public:
    Base()
    {
        cout << "Base()" << endl;
    }

    Base(int ibase)
    : _ibase(ibase)
    {
        cout << "Base(int)" << endl;
    }

    ~Base()
    {
        cout << "~Base()" << endl;
    }
protected:
    int _ibase;
};

class Derived
: virtual public Base
{
public:
    Derived()
    {
        cout << "Derived()" << endl;
    }

    Derived(int ibase, int iderived)
    /* : Base(ibase) */
    : _iderived(iderived)
    {
        cout << "Derived(int, int)" << endl;
    }

    ~Derived()
    {
        cout << "~Derived()" << endl;
    }
protected:
    int _iderived;
};

class Derived2
: public Derived
{
public:
    Derived2(int x, int y, int z)
    : Base(x)
    , Derived(x, y)
    , _id(z)
    {
        cout << "Derived2(int, int, int)" << endl;
    }

    void print()
    {
        cout << "_ibase = " << _ibase << endl
             << "_iderived = " << _iderived << endl
             << "_id = " << _id << endl;
    }
    ~Derived2()
    {
        cout << "~Derived2()" << endl;
    }
private:
    int _id;
};


int main(int argc, char *argv[])
{
    Derived2 d(10, 20, 30);
    d.print();

    return 0;
}

